package com.yyk.yykywd.mvvm.view_model

import androidx.lifecycle.MutableLiveData
import com.yyk.yykywd.mvvm.entity.HomeBean
import com.yyk.yykywd.mvvm.model.HomeModel

/**
 * 文件描述：
 * Created by guo on 2019-11-26.
 */
class NewHomeViewModel : BaseViewModel() {
    var business: MutableList<String> = ArrayList()

    private val homeModel = HomeModel()
    //LiveData,使该数据可以被感知
    var departments = MutableLiveData<HomeBean>()

    fun getDepartments() {
        homeModel.getDepartmentList("0",object : HomeModel.GetHome{
            override fun getInfo(home: HomeBean) {
                business.clear()
                for (department in home.data.department) {
                    business.add(department.name)
                }
                departments.value = home
            }

            override fun onError(e: String) {
                error.value = e
            }

        })
    }
}